package com.example.tests;

import java.util.Collections;
import java.util.List;

import org.testng.Assert;
import org.testng.annotations.Test;

public class ContactModificationTests extends TestBase {
	
	@Test
	public void testEditContact() {
		app.getNavigationHelper().openMainPage();
		
		List<ContactData> oldList = app.getContactHelper().getContacts();
		  
		app.getContactHelper().initContactEditing(1);
		ContactData contact = new ContactData();
		contact.firstName = "new first name";
		contact.lastName = "new last name";
		contact.email = "new@new.new";
		contact.homeNumber = "11-22-33";
		app.getContactHelper().fillContactForm(contact);
		app.getContactHelper().submitContactEditing();
		app.getContactHelper().returnToHomePage();
		
		List<ContactData> newList = app.getContactHelper().getContacts();
	      
		oldList.remove(0);
	    oldList.add(contact);
		Collections.sort(oldList);
		Collections.sort(newList);
		
		Assert.assertEquals(newList, oldList);
	}

}
